package com.lin.start.autoconfiguration;

import com.lin.start.format.FastJsonFormat;
import com.lin.start.format.Format;
import com.lin.start.format.StringFormat;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;



@Configuration
public class FormatAutoconfiguration {

    @ConditionalOnMissingClass("com.alibaba.fastjson.JSON")
    @Bean
    @Primary
    public Format stringFormat(){
        return new StringFormat();
    }

    @ConditionalOnClass(name = "com.alibaba.fastjson.JSON")
    @Bean
    public Format fastJsonFormat(){
        return new FastJsonFormat();
    }
}
